package com.study.login.service;

import com.study.login.dao.LoginDao;
import com.study.common.entity.User;
import com.study.login.entity.Identity;
import com.study.login.entity.Jurisdiction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Create by ldr.
 * @create 2018-08-28 14:26
 * @Description：登陆逻辑层实现类
 */
@Service(value = "loginService")
public class LoginServiceImpl implements LoginService {

    @Autowired
    @Qualifier(value = "loginDao")
    private LoginDao loginDao;

    @Override
    public User getUserByUserName(String userName) {
        return loginDao.getUserByUserName(userName);
    }

    @Override
    public Identity getIdentityByUser(String userName) {
        return loginDao.getIdentityByUser(userName);
    }

    @Override
    public List<String> getJurisdictionNameById(int identityId) {
        List<Jurisdiction> jurisdictionList = loginDao.getJurisdictionById(identityId);
        List<String> stringList = new ArrayList<String>();
        for (Jurisdiction jurisdiction : jurisdictionList) {
            stringList.add(jurisdiction.getJurisdictionName());
        }
        return stringList;
    }


}
